package ar.pmt.vista.decoradores;

import java.util.Date;

import javax.servlet.jsp.PageContext;

import org.apache.commons.lang.time.FastDateFormat;
import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;

import ar.pmt.vista.utils.Utils;

public class ShortDateTimeWrapper implements DisplaytagColumnDecorator
{

    public ShortDateTimeWrapper()
    {
        dateFormat = FastDateFormat.getInstance("dd/MM/yyyy HH:mm");
    }

    public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media)
        throws DecoratorException
    {
        String dateStr = (String)columnValue;
       Date date = Utils.stringToLongDate(dateStr);
        if (date==null) {
           return "";
        }
        return dateFormat.format(date);
    }

    private FastDateFormat dateFormat;
}